<?php
class ErrorController 
    extends Zend_Controller_Action
{

    protected $_devEnvs = array (
    	'development', 'devpablo', 'devpabloit'
    );
    
    public function errorAction()
    {
        $errors = $this->_getParam('error_handler');
        
        switch ($errors->type) { 
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
        
                // 404 error -- controller or action not found
                $this->getResponse()->setHttpResponseCode(404);
                $this->view->message = $this->view->translate('pageNotFound');
                break;
            default:
                // application error 
                $this->getResponse()->setHttpResponseCode(500);
                $this->view->message = '';
                
                
                break;
        }
         
		if ( in_array(APPLICATION_ENV, $this->_devEnvs) || $this->getRequest()->getClientIp() == '186.18.88.130'){
            ?>
		    <h3>Exception information:</h3>
            <p><b>Message:</b> <?php echo $errors->exception->getMessage() ?></p>
            <h3>Stack trace:</h3>
            <?php Zend_Debug::dump( $errors->exception->getTraceAsString()) ?>
            
            <h3>Request Parameters:</h3>
            <?php Zend_Debug::dump( var_export($this->_request->getParams(), true)) ?>
		    
		    <?php
		}
		
		$this->getHelper('Log')->exception( $errors->exception );
		
		exit;
    }


}

